<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script type="text/javascript">
    var jsonObj = {
        //number 类型
        'key1': 1234,
        //string 类型
        'key2': 'abcdef',
        //boolean 类型
        'key3': false,
        //Array 类型
        key4: [true, 100, 'xyz'],
        //object 类型
        key5: {
            key5_1: 51,
            key5_2: "key5_2_value"
        },
        //对象数组类型
        "key6": [{
            key6_1_1: 611,
            key6_1_2: 'key6_1_2_value'
        }, {
            key6_2_1: 621,
            key6_2_2: 'key6_2_2_value'
        }]
    };
    console.log(jsonObj);
    console.log(jsonObj.key1);
    console.log(jsonObj.key2);
    console.log(jsonObj.key3);
    for (let i = 0; i < jsonObj.key4.length; i++) {
        console.log(jsonObj.key4[i]);
    }
    console.log(jsonObj.key5.key5_1);
    console.log(jsonObj.key5.key5_2);
    console.log(jsonObj.key6[0].key6_1_1);
    console.log(jsonObj.key6[0].key6_1_2);
    console.log(jsonObj.key6[1].key6_2_1);
    console.log(jsonObj.key6[1].key6_2_2);
    //object
    console.log(typeof jsonObj);
    jsonObj.key7 = 777;
    console.log(jsonObj);

    //JSON 对象 转 字符串
    //json字符串格式 无法进行属性的取值赋值 只能用于传输
    var jsonStr = JSON.stringify(jsonObj);
    console.log(typeof jsonStr);
    console.log(jsonStr);
    //undefined
    console.log(jsonStr.key1);

    //JSON 字符串 转 对象
    var obj = JSON.parse(jsonStr);
    //object
    console.log(typeof obj);
    console.log(obj);
    //1234
    console.log(obj.key1);

</script>
</html>